package com.example.demo;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import java.io.IOException;

public class Dialog extends Application {

    Button enter = new Button("登录");
    Button close = new Button();
    @Override
    public void start(Stage stage) throws Exception {
        System.out.println(getClass().getResource("Dialog.fxml"));
        Pane root = FXMLLoader.load(getClass().getResource("Dialog.fxml"));
        Scene scene = new Scene(root,448,397);
        //设置样式
        close.setId("close");
        close.setLayoutX(410);
        close.setLayoutY(0);
        close.setPrefWidth(37);
        close.setPrefHeight(36);
        close.setOnAction(actionEvent -> {
            stage.close();
        });

        enter.setId("enter");
        enter.setLayoutX(93);
        enter.setLayoutY(351);
        enter.setPrefWidth(264);
        enter.setPrefHeight(30);
        enter.setStyle("-fx-font-size: 16");
        //点击登录即可打开软件
        enter.setOnAction(actionEvent -> {
            HelloApplication helloApplication = new HelloApplication();
            try {
                helloApplication.start(new Stage());
                stage.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
        root.getChildren().addAll(close,enter);
        stage.initStyle(StageStyle.UNDECORATED);
        stage.setScene(scene);
        stage.show();
    }

    public void close(ActionEvent actionEvent) {
        System.out.println(1);
    }
}
